package com.spgf.controller;

import java.util.Calendar;
import java.util.List;

import android.os.Bundle;
import android.widget.ListView;

import com.archtecture.model.exceptions.NegocioException;
import com.spgf.model.entities.CategoriaModel;
import com.spgf.model.enums.Mes;
import com.spgf.model.rn.CategoriaRN;
import com.spgf.view.utils.AdapterListViewCategorias;

public class RelatorioCategoriasActivity extends PadraoActivity {

	private ListView	listview;

	@Override
	protected void construirTela(Bundle savedInstanceState) throws NegocioException {
		setContentView(R.layout.activity_relatorio_categoria);

		listview = (ListView) findViewById(R.id.lst_relatorio_categorias);
		listview.setScrollbarFadingEnabled(true);
		listview.setOnItemLongClickListener(this);

		listview.setAdapter(new AdapterListViewCategorias(this, getListaModel()));

	}

	private List<CategoriaModel> getListaModel() throws NegocioException {

		Mes lMes = Mes.values()[Calendar.getInstance().get(Calendar.MONTH)];
		String lAno = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));

		return new CategoriaRN(this).obterResumoMensalCategorias(lMes, lAno);
	}
}
